package cn.itcast.test1;

import cn.itcast.test1.util.Sleeper;
import lombok.extern.slf4j.Slf4j;

public class TestMultiLock {
    public static void main(String[] args) {
        BigRoom bigRoom = new BigRoom();
        new Thread(() -> {
            bigRoom.sleep();
        }).start();
        new Thread(() -> {
            bigRoom.study();
        }).start();
    }
}

@Slf4j(topic = "c.BigRoom")
class BigRoom{
    private static final  Object studyRoom = new Object();
    private static final  Object sleepRoom = new Object();

    public void sleep(){
        synchronized (sleepRoom){
            log.debug("小女在睡觉");
            Sleeper.sleep(2);
        }
    }

    public void study(){
        synchronized (studyRoom){
            log.debug("小南在学习");
            Sleeper.sleep(2);
        }
    }
}
